function flat(arr) {
  const isDeep = arr.some(item => item instanceof Array)
  if (!isDeep) {
    return arr  //已经是flatern
  }
  const res = [].concat(...arr)   //arr里的每个元素都会通过concat连接
  return flat(res)
}

const res = flat([1, 2, [3, 4, [7, 8]], 5])
console.log(res);

